import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import *

testCase = "DBshop019_添加属性组"
# "1.点击“添加属性”按钮，编写属性分组“好好学习”，属性类型“下拉”，属性名称“天天向上”，排序“255”。
firefox = openBrowser(urlAdmin)
DBshopLoginAdmin(firefox)

DBshopEnterMenu3(firefox, "商品管理", "商品属性","属性分组")
firefox.find_element_by_link_text("添加属性组").click()
firefox.find_element_by_id("attribute_group_name").send_keys("好好学习")
firefox.find_element_by_id("attribute_group_sort").clear()
firefox.find_element_by_id("attribute_group_sort").send_keys("1")
# 点击“保存属性分组信息”";添加属性组成功
firefox.find_element_by_xpath("//button").click()


DBshopEnterMenu3(firefox, "商品管理", "商品属性","属性")
firefox.find_element_by_link_text("添加属性").click()
firefox.find_element_by_xpath("//select[@id='attribute_group_id']/option[2]").click()
# 2.点击“保存属性信息”按钮，保存成功。";添加属性信息成功
firefox.find_element_by_id("attribute_name").send_keys("天天向上")
firefox.find_element_by_xpath("//button").click()

time.sleep(5)
# 断言
if firefox.find_element_by_xpath("//tr[1]/td[2]").text=="天天向上":
    writeLog("%s 测试通过" % testCase)
else:
    writeLog("%s 测试失败" % testCase)
firefox.quit()
